package nz.ac.massey.cs.se400_2013.ass3.gui;

import java.awt.GridLayout;

import javax.swing.JFrame;

import nz.ac.massey.cs.se400_2013.ass3.message.Message;
import nz.ac.massey.cs.se400_2013.ass3.message.MessageListener;
import nz.ac.massey.cs.se400_2013.ass3.message.MessageType;

public class Runner {

	private JFrame frame = new JFrame();
	private Tool tool = new Tool();
	private SideTree sideTree = new SideTree();

	public Runner() {
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

		frame.setLayout(new GridLayout(2, 2));

		// Add content to the window.
		sideTree.addMessageListener(new SideTreeMessageListener());
		frame.add(tool);
		frame.add(sideTree);
		

		frame.pack();
		frame.setVisible(true);
	}

	public static void main(String[] args) {

		new Runner();

		// Student student = new Student();
		// student.setFirstName("bob");
		// student.setName("no idea");
		// StudentEditor editor = new StudentEditor();
		// frame.add(editor.getEditor());
		// editor.edit(student);
		// frame.setSize(500, 500);
		// frame.setVisible(true);
	}

	/**
	 * @author Chen
	 */
	private class SideTreeMessageListener implements MessageListener {

		@Override
		public void messageReceived(Message message) {
			MessageType messageType = message.getType();

			switch (messageType) {
			case LEFT_CLICK:
				Tool.toggleButtons(message.getBody().toString());
				System.out.println(message.getBody().toString());
				break;

			default:
				break;
			}

		}

	}

}
